package br.com.prezz.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.ValuePicker;
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
import com.google.gwt.event.logical.shared.AttachEvent;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Admin implements EntryPoint {
	@Override
	public void onModuleLoad() {
	
		RootPanel rootPanel = RootPanel.get("Upload");
		rootPanel.setWidth("100%");
		
		VerticalPanel Options = new VerticalPanel();
		Options.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		Options.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		rootPanel.add(Options, 0, 10);
		Options.setSize("100%", "56px");
		
		VerticalPanel Type = new VerticalPanel();
		Options.add(Type);
		Type.setBorderWidth(0);
		Type.setSize("191px", "44px");
		
		RadioButton radioButton = new RadioButton("new name", "Supermercados");
		Type.add(radioButton);
		
		RadioButton radioButton_1 = new RadioButton("new name", "Produtos");
		radioButton_1.setChecked(true);
		Type.add(radioButton_1);
		
		VerticalPanel File = new VerticalPanel();
		File.setStyleName("upload");
		
	
		File.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		rootPanel.add(File, 0, 88);
		File.setSize("100%", "24px");
		
		FileUpload fileUpload = new FileUpload();
		fileUpload.addAttachHandler(new Handler() {
			public void onAttachOrDetach(AttachEvent event) {
				// TODO: Verificar se eh um arquivo csv
				// TODO: Verificar as colunas do csv
				// TODO: Enviar o arquivo
			}
		});
		File.add(fileUpload);
		fileUpload.setWidth("367px");
		
		VerticalPanel verticalPanel = new VerticalPanel();
		verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		rootPanel.add(verticalPanel, 0, 120);
		verticalPanel.setSize("100%", "26px");
		
		HorizontalPanel horizontalPanel = new HorizontalPanel();
		horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		verticalPanel.add(horizontalPanel);
		horizontalPanel.setWidth("30%");
		
		SimplePanel simplePanel = new SimplePanel();
		horizontalPanel.add(simplePanel);
		simplePanel.setWidth("90px");
		
		Button btnCancelar = new Button("Cancelar");
		btnCancelar.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				// TODO: Cancelar
			}
		});
		simplePanel.setWidget(btnCancelar);
		btnCancelar.setSize("80px", "100%");
		
		SimplePanel simplePanel_1 = new SimplePanel();
		horizontalPanel.add(simplePanel_1);
		simplePanel_1.setWidth("90px");
		
		Button btnEnviar = new Button("Enviar");
		btnEnviar.setText("Upload");
		simplePanel_1.setWidget(btnEnviar);
		btnEnviar.setSize("80px", "100%");
	}
}
